import 'package:flutter/material.dart';
import 'package:haokezufang/widgets/common_image.dart';

import 'info_data.dart';

class IndexInfoItem extends StatelessWidget {
  final InfoItem data;

  const IndexInfoItem({super.key, required this.data});
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pushNamed(data.navigateUrl);
      },
      child: Container(
        height: 100,
        padding: const EdgeInsets.all(10),
        decoration: const BoxDecoration(color: Colors.white),
        margin: const EdgeInsets.only(left: 10, right: 10, top: 10),
        child: Row(
          children: [
            CommonImage(
              src: data.imageUrl,
              width: 120,
              height: 90,
              fit: BoxFit.cover,
            ),
            const Padding(padding: EdgeInsets.only(left: 10)),
            Expanded(
                child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  alignment: Alignment.centerLeft,
                  child: Text(
                    data.title,
                    maxLines: 2,
                    style: const TextStyle(
                        fontWeight: FontWeight.w600, color: Colors.black),
                  ),
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [Text(data.source), Text(data.time)],
                )
              ],
            ))
          ],
        ),
      ),
    );
  }
}
